<?php

class Zone extends Datamapper {
    
	var $table = 'zones';
	
	var $has_many = array(
		'countries' => array(
			'class' => 'country',
			'other_field' => 'zone',
			'join_self_as' => 'zone',
			'join_other_as' => 'country',
			'join_table' => 'r_countries_zones'),
		'ngos' => array(
			'class' => 'ngo',
			'other_field' => 'zone',
			'join_self_as' => 'zone',
			'join_other_as' => 'ngo',
			'join_table' => 'r_ngos_zones'),
	);
	
	static function get_array()
    {
    	$ci =& get_instance();
    	$ci->db->select("id, ".$ci->session->userdata('uilang')." as label");
    	$ci->db->order_by('label', 'ASC');
    	$q = $ci->db->get('zones');

    	if($q->num_rows() > 0 )  {
    		$res = array();
    		foreach($q->result() as $row) {
    			$res[$row->id] = $row->label;
    		}
    		return $res;
    	}
    	return NULL;
    }
}

/* End of file country.php */
/* Location: ./application/models/country.php */